package com.jdkreader.lambada;


/**
 * Java 8 default关键字示例接口
 */
public interface Formula {

    double calculate(int a);


    default double sqrt(int a){
        return Math.sqrt(a);
    }


    public static void main(String[] args) {

        Formula formula = new Formula() {
            @Override
            public double calculate(int a) {
                //接口实现类直接调用接口的default方法
                return sqrt(a * 100);
            }
        };



        System.out.println(formula.calculate(100));

        System.out.println( formula.sqrt(20));
    }

}
